function e(t) {
    if (t.data.second > 0) {
        var a = t.data.second - 1;
        t.setData({
            isSendEnable: !1,
            second: a,
            sendClass: "right",
            sendText: a + "秒重发",
            phoneDisable: !0
        }), o = setTimeout(function() {
            e(t);
        }, 1e3);
    } else t.setData({
        isSendEnable: !0,
        sendText: "发送",
        sendClass: "right_active",
        second: 60,
        phoneDisable: !1,
        tipShow: "block"
    });
}

var t = getApp(), a = require("../../component/WxNotificationCenter/WxNotificationCenter.js"), o = null;

Page({
    data: {
        isSendEnable: !1,
        sendClass: "right",
        second: 60,
        sendText: "发送",
        phoneDisable: !1,
        tipShow: "none",
        phone: "",
        code: ""
    },
    bindPhoneInput: function(e) {
        var t = e.detail.value;
        11 == t.length ? this.setData({
            isSendEnable: !0,
            sendClass: "right_active",
            phone: t
        }) : this.setData({
            isSendEnable: !1,
            sendClass: "right",
            phone: t
        });
    },
    bindCodeInput: function(e) {
        var t = e.detail.value;
        this.setData({
            code: t
        });
    },
    sendCode: function(a) {
        if (this.data.isSendEnable) {
            if (!t.util.validatemobile(this.data.phone)) return void t.util.showToast("请输入正确的手机号码");
            var o = this;
            t.network.post({
                url: t.url.loginSendCode,
                params: {
                    phone: o.data.phone
                },
                before: function() {
                    wx.showLoading({
                        title: "提交数据"
                    });
                },
                success: function(a) {
                    wx.hideLoading(), 1 == a.data.result ? (e(o), t.util.showToast(a.data.message)) : t.util.showToast(a.data.message);
                },
                fail: function() {
                    wx.hideLoading(), t.util.showToast("发送验证码失败");
                },
                complete: function() {}
            });
        }
    },
    login: function(e) {
        var o = this.data.phone, n = this.data.code;
        if (t.util.validatemobile(o)) if (0 != n.length) if (4 == n.length) {
            var s = this;
            t.network.post({
                url: t.url.loginCheck,
                params: {
                    phone: s.data.phone,
                    smsCode: s.data.code,
                    openId: wx.getStorageSync(t.storage.openid)
                },
                before: function() {
                    wx.showLoading({
                        title: "登录中"
                    });
                },
                success: function(e) {
                    wx.hideLoading(), 1 == e.data.result ? (console.log(e.data), t.util.showToast(e.data.message), 
                    t.globalData.accessToken = e.data.data.accessToken, t.globalData.firstLogin = !0, 
                    wx.setStorageSync(t.storage.accessToken, e.data.data.accessToken), wx.setStorageSync(t.storage.role, e.data.data.role), 
                    wx.setStorageSync(t.storage.hunyu, e.data.data.hunyu), t.util.updateUserInfo(), 
                    t.util.lastAccessServer(), a.postNotificationName("didLoginSuccess"), wx.navigateBack({
                        delta: 2
                    })) : 2 == e.data.result ? wx.navigateTo({
                        url: "/pages/login/selectRole/selectRole?phone=" + s.data.phone
                    }) : t.util.showToast(e.data.message);
                },
                fail: function() {
                    wx.hideLoading(), t.util.showToast("登录失败，请重试");
                },
                complete: function() {}
            });
        } else t.util.showToast("验证码错误"); else t.util.showToast("请输入验证码"); else t.util.showToast("请输入正确的手机号码");
    },
    bindTipTap: function(e) {
        wx.showModal({
            title: "提示",
            content: "收不到验证码请加微信客服，\n微信号：18883316110",
            confirmColor: t.globalData.themeColor,
            confirmText: "复制微信",
            success: function(e) {
                e.confirm ? wx.setClipboardData({
                    data: "18883316110",
                    success: function(e) {
                        t.util.showToast("复制成功！");
                    }
                }) : e.cancel;
            }
        });
    },
    onLoad: function(e) {},
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            title: t.globalData.commonShareTitle,
            path: t.globalData.commonSharePath,
            success: function(e) {},
            fail: function(e) {}
        };
    }
});